package com.xunyin.modules.coupon.rest;


import com.xunyin.api.ApiResult;
import com.xunyin.modules.log.AppLog;
import com.xunyin.modules.couponnew.service.UserCouponService;
import com.xunyin.web.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * 我的卡券接口controller
 * <p>
 * Created by xunyinyunshang <3594419785@qq.com>
 * CopyRight 讯音云商 https://www.tonetn.com
 */
@Slf4j
@RestController
@Api(value = "我的卡券接口相关", tags = "共享空间:我的卡券接口相关")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class ClientMyCouponController {

    private final UserCouponService userCouponService;

    /**
     * 查询我的卡券
     */
    @AppLog(value = "查询我的卡券", type = 1)
    //@AuthCheck
    @PostMapping("/myCoupon/list")
    @ApiOperation(value = "查询我的卡券列表", notes = "查询我的卡券列表")
    public ApiResult<Map<String, Object>> list(HttpServletRequest request, @RequestBody Map<String, Object> param) {
/*        String token = request.getHeader("Access-Token");
        String status = request.getParameter("status") == null ? "" : request.getParameter("status");
        String type = request.getParameter("type") == null ? "" : request.getParameter("type");

        if (StringUtil.isEmpty(token)) {
            return getFailureResult(1001);
        }

        UserInfo mtUser = TokenUtil.getUserInfoByToken(token);
        if (null == mtUser) {
            return getFailureResult(1001);
        }

        Map<String, Object> param = new HashMap<>();
        param.put("userId", mtUser.getId());
        param.put("status", status);
        param.put("type", type);*/
        Map<String, Object> data = new HashMap();
        ResponseObject result = userCouponService.getUserCouponList(param);
        data.put("myCouponList", result.getData());
        return ApiResult.ok(data);
        //return getSuccessResult(result.getData());
    }

}
